package com.luban.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * Advisor = Advice(代理逻辑) + Pointcut(切点)
 */

@Aspect
@Component
public class LubanAspect {

	//@Before(value = "execution(public void com.luban.service.UserService.test())")
	//public void lubanBefore() {
	//}


	@Pointcut
	public void xxx() {

	}


	@Before(value = "execution(public void com.luban.service.UserService.test())")
	public void lubanBefore() {
		System.out.println("before");
	}

	@After(value = "execution(public void com.luban.service.UserService.test())")
	public void lubanAfter() {
		System.out.println("after");
	}

	@AfterReturning(value = "execution(public void com.luban.service.UserService.test())")
	public void lubanAfterReturning() {
		System.out.println("afterReturning");
	}

	@AfterThrowing(value = "execution(public void com.luban.service.UserService.test())")
	public void lubanAfterThrowing() {
		System.out.println("afterThrowing");
	}

	@Around(value = "execution(public void com.luban.service.UserService.test())")
	public void lubanAround(ProceedingJoinPoint joinPoint) {

		try {
			System.out.println("执行前");
			joinPoint.proceed();
			System.out.println("执行后");
		} catch (Throwable e) {
			e.printStackTrace();
		}

	}


}
